package com.example.lib_base.net

import android.content.Context
import androidx.room.Room
import com.example.lib_base.db.ParkDataBase
import com.example.lib_base.db.SearchDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ProviderFactory {

    @Provides
    @Singleton
    fun getApiService():ApiService = RetrofitUtils.getRetrofit().create(ApiService::class.java)

    @Provides
    @Singleton
    fun initDB(@ApplicationContext context:Context):ParkDataBase{
        return Room.databaseBuilder(context,ParkDataBase::class.java,"park2212.db")
            .build()
    }

    @Provides
    @Singleton
    fun getSearchDao(dataBase: ParkDataBase):SearchDao = dataBase.searchDao()
}